package str_match

// 暴力搜索算法
func BruteForce(text string, pattern string) (result []int) {
	m, n := len(text), len(pattern)
	i, j := 0, 0
	for {
		if i > m-1 {
			break
		}
		step := 0
		for {

			if i+step > m-1 {
				break
			}

			if text[i+step] == pattern[j] {
				step++
				j++
			} else {
				j = 0
				i++
				break
			}

			if step == n {
				result = append(result, i)
				j = 0
				i++
				break
			}
		}

	}

	return
}
